<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head th:include="admin/common :: commonhead">
    <!--<div th:replace="admin/common :: commonhead"></div>-->
</head>
<head>
    <title>专业管理</title>
    <!--这里写这个页面单独需要的css-->
</head>
<body class="sticky-header">

<section>
    <!--  引入左侧边  -->
    <div th:replace="admin/common :: left"></div>

    <div class="main-content">
        <div th:replace="admin/common :: header-section"></div>
        <!--这里开始写东西-->
        <div class="wrapper">
            <div class="row">
                <div class="col-sm-12">
                    <section class="panel">
                        <header class="panel-heading">
                            专业管理
                            <span class="tools pull-right">
                              <a href="javascript:;" class="fa fa-chevron-down"></a>
                              <a href="javascript:;" class="fa fa-times"></a>
                            </span>
                        </header>
                        <div class="panel-body">
                            <div class="">
                                <a class="btn btn-success" data-toggle="modal" href="#myModal">添加</a>
                                <span th:text="${add_msg}" th:if="${not #strings.isEmpty(add_msg)}"></span>
                            </div>
                            <div class="adv-table editable-table ">
                                <div class="space15"></div>
                                <table class="table  table-hover table-bordered" id="editable-sample">
                                    <thead>
                                    <tr>
                                        <th>专业名称</th>
                                        <th>编辑</th>
                                        <th>删除</th>
                                    </tr>
                                    </thead>
                                    <tbody th:each="major : ${majors.records}">
                                    <tr class="">
                                        <td>[[${major.mjName}]]</td>
                                        <td><a th:href="@{/admin/major/}+${major.mjName}"
                                               class="btn btn-success">编辑</a></td>
                                        <td>
                                            <form method="post" th:action="@{/admin/deletemajor/}+${major.mjName}">
                                                <input type="hidden" name="_method" value="delete">
                                                <button class="btn btn-danger" type="submit"
                                                        onclick="return confirm('确认要删除吗？')">删除
                                                </button>
                                            </form>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>

                            <div class="row">
                                <div class="col-lg-6">
                                    <div class="dataTables_info" id="editable-sample_info">
                                    </div>
                                </div>
                                <div class="col-lg-6">
                                    <div class="dataTables_paginate paging_bootstrap pagination">
                                        <ul>
                                            <li class="prev">
                                                <a th:href="@{/admin/majors(pn=${majors.current - 1 < 1 ? 1 : majors.current - 1})}">←
                                                    上一页</a>
                                            </li>
                                            <li th:class="${num == majors.current ? 'active' : ''}"
                                                th:each="num : ${#numbers.sequence(1, majors.pages)}">
                                                <a th:href="@{/admin/majors(pn=${num})}" th:text="${num}"></a>
                                            </li>
                                            <li class="next">
                                                <a th:href="@{/admin/majors(pn=${majors.current + 1 > majors.pages ? majors.pages : majors.current + 1})}">下一页
                                                    → </a>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>

                        </div>
                    </section>
                </div>
            </div>

            <!-- Modal -->
            <div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="myModal"
                 class="modal fade">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title">详细信息</h4>
                        </div>
                        <form th:action="@{/admin/addMajor}" method="post">
                            <div class="modal-body">
                                <input type="text" autofocus="" placeholder="专业名称" class="form-control" name="mjName">
                                <br>

                            </div>
                            <div class="modal-footer">
                                <button data-dismiss="modal" class="btn btn-default" type="button">取消</button>
                                <button class="btn btn-primary" type="submit">添加</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <!-- modal -->

        </div>
    </div>
</section>

<div th:replace="admin/common :: commonjs"></div>
<!--data table-->
<script type="text/javascript" th:src="@{/js/data-tables/jquery.dataTables.js}"></script>
<script type="text/javascript" th:src="@{/js/data-tables/DT_bootstrap.js}"></script>
<script src="js/bootstrap.min.js" th:src="@{/js/bootstrap.min.js}"></script>
<script src="js/modernizr.min.js" th:src="@{/js/modernizr.min.js}"></script>
<!--script for editable table-->
<script th:src="@{/js/editable-table.js}"></script>

</body>
</html>